package org.aplikator.client.descriptor;

import java.io.Serializable;

import org.aplikator.client.widgets.FormWidget;
import org.aplikator.client.widgets.TextFieldWidget;

import com.google.gwt.user.client.ui.Widget;

@SuppressWarnings("serial")
public class TextFieldDTO<T extends Serializable> implements WidgetDTO {

    private PropertyDTO<T> property;

    private boolean labelAbove = false;

    private String width;

    @SuppressWarnings("unused")
    private TextFieldDTO() {
    }

    public TextFieldDTO(PropertyDTO<T> property) {
        this.property = property;
    }

    public Widget getWidget(FormWidget form) {
        TextFieldWidget<T> field = new TextFieldWidget<T>(property.getLocalizedName(), property, labelAbove, width);
        form.registerDataField(field);
        return field;
    }

    public boolean isLabelAbove() {
        return labelAbove;
    }

    public void setLabelAbove(boolean labelAbove) {
        this.labelAbove = labelAbove;
    }

    public void setWidth(String width) {
        this.width = width;
    }

    public String getWidth() {
        return width;
    }

}
